<!doctype html>
<html style="height:100%;">
<head>
<meta charset="utf-8">
<meta content="WangID通城" http-equiv="keywords">
<meta name="description" content="WangID通城">
<meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
<title>WangID通城</title>
<link rel="stylesheet" href="css/index.css" type="text/css">
<link rel="stylesheet" href="css/zy.css" type="text/css">
<link rel="stylesheet" href="css/swiper.min.css" type="text/css">
<script type="text/javascript" src="js/swiper.min.js"></script>
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
	<script src="/js/common.js"></script>
</head>
<body style="height: 100%;"> 
<!--页面内容
<div id="yemnr">--> 
<!--头部--> 
<div class="toub_beij toub_beij_zy">
	<div class="zhongj_k zhongj_k_z">
		<div class="jiu_feo">
			<div class="logo_k logo_k_fanh"><a href="javascript:history.go(-1)"><img class="fanh_ann" src="images/web/fanh.png"></a></div>
			<div class="zhongjain_daoh">
				<ul>
					<li><a class="px24 zyyge"></a></li>
				</ul>
			</div>
		</div> 
	</div>
</div>
<script type="text/javascript">
	//滑动头部透明（针对首页头部用）
	window.onscroll=function(){

	var autoheight=document.body.scrollTop||document.documentElement.scrollTop;
	if(autoheight>10){
		$(".toub_beij").css("position" ,"fixed")
		}else{
			$(".toub_beij").css("position" ,"relative")
		}
	}
</script>
<!--内容-->
<div class="shouhdz_hk">
	<div class="shouh_zk">
		<div class="shouh_dange_beijin">
			<div class="denglu_k denglu_k_k">
				<div class="denglk denglk_l">
					<div class="mz px24">收货人：</div>
					<input type="text" id="name" placeholder="收货人名字">
				</div>
				<div class="denglk denglk_l">
					<div class="mz px24">联系方式：</div>
					<input type="text" id="tel" placeholder="手机号码">
				</div>
				<!--<div class="denglk denglk_l">
					<div class="mz px24">所在地区：</div>
					<div class="browser">
				        &lt;!&ndash;选择地区&ndash;&gt;
				        <section class="express-area">
				            <a id="expressArea" href="javascript:void(0)">
				                <dl>
				                    <dt></dt>
				                    <dd>省 > 市 > 区/县</dd>
				                </dl>
				            </a>
				        </section>
				        &lt;!&ndash;选择地区弹层&ndash;&gt;
				        <section id="areaLayer" class="express-area-box">
				            <header>
				                <h3>选择地区</h3>
				                <a id="backUp" class="back" href="javascript:void(0)" title="返回"></a>
				                <a id="closeArea" class="close" href="javascript:void(0)" title="关闭"></a>
				            </header>
				            <article id="areaBox">
				                <ul id="areaList" class="area-list"></ul>
				            </article>
				        </section>
				        &lt;!&ndash;遮罩层&ndash;&gt;
				        <div id="areaMask" class="mask"></div>
				        <script src="js/jquery.area.js"></script>
				    </div>
				</div>-->
				<div class="denglk denglk_l">
					<div class="mz px24">详细地址：</div>
					<input type="text" id="detail" placeholder="">
				</div> 
			</div>
		</div>
		<div class="shouh_dange_beijin dk"><a id="submit">确 认</a></div>
	</div>
</div>  
<!--大框div
</div>-->
<!--搜索页面-->

<script>
	function getUrl(arr) {
        var url ="";
        if (getParams().cartId) {
            $.each(arr , function (i , n) {
                if (!url){
                    url = url + "cartId=" +n;
                } else {
                    url = url + "&" + "cartId=" +n;
                }
            });
        } else {
            url = getParam().substr(1);
		}
	    return url;
    }

	$(function () {
	    var userId = getUser().id;
	    var addressId = getParams().id;
        console.log(getParamss2());
        var url = getUrl(getParamss2());
        console.log(url);
        // console.log(addressId);
        if (addressId){
            $(".zhongjain_daoh a").html("修改收货地址");
            $.get("/addresses/"+addressId , function (data) {
                // console.log(data);
				$("#name").val(data.name);
				$("#tel").val(data.tel);
				$("#detail").val(data.detail);
            })
		} else {
            $(".zhongjain_daoh a").html("新添收货地址");
		}

		$("#submit").click(function () {
            console.log(123);
            var name = $("#name").val();
            var tel = $("#tel").val();
            var detail = $("#detail").val();
            if (addressId) {
                $.ajax({
					type:"PUT",
					url:"/addresses",
					data:{name:name,tel:tel,detail:detail,id:addressId},
                    success:function (data) {
					    if (url) {
                            location.href = "/shopping/productAdd.html?"+url;
						} else {
                            location.href = "/shopping/productAdd.html";
                        }
                    }
				})
			} else {
                $.ajax({
                    type:"POST",
                    url:"/addresses",
                    data:{name:name,tel:tel,detail:detail,userId:userId},
                    success:function (data) {
                        if (url) {
                            location.href = "/shopping/productAdd.html?"+url;
                        } else {
                            location.href = "/shopping/productAdd.html";
                        }
                    }
                })
			}
        });


    })
</script>

</body>
</html>

<!-- <script type="text/javascript">
	window.onload=function(){ 
		var TheMenu=document.getElementById('zhu_caid');
		var LieBiao=document.getElementById('daoh_lb'); 
		var Html=document.getElementsByTagName("html")[0];//0 第一个数组
		TheMenu.onclick=function(event)
		{
			if (LieBiao.style.display=='block')
			{
				LieBiao.style.display='none';
			}
			else {
				LieBiao.style.display='block';
			}  
			event.stopPropagation();//阻止冒泡事件
		} 
		Html.onclick=function(){
			LieBiao.style.display='none';
		}

		// 
		 
 };
 
</script> -->